package nayasis.common.ui.javaFx.dialog;

import javafx.event.Event;
import javafx.event.EventHandler;
import nayasis.common.util.StringUtil;

public abstract class Dialog {

	private static DialogManager dialogManager = new DialogManager();
	private static boolean confirmResult = false;
	
	public static void alert( String format, Object... param ) {

		String message = StringUtil.format( format, param );
		
		dialogManager.setTitle( "알림" );
		dialogManager.setIconInfo();
		dialogManager.setMessage( message );
		dialogManager.addButton( "확인" );
		dialogManager.display( true );
		
	}
	
	@SuppressWarnings("rawtypes")
	public static boolean confirm( String format, Object... param ) {

		String message = StringUtil.format( format, param );
		
		confirmResult = false;
		
		dialogManager.setTitle( "확인" );
		dialogManager.setIconInfo();
		dialogManager.setMessage( message );
		dialogManager.addButton( "예", new EventHandler() {
			public void handle(Event arg) {
				confirmResult = true;
			}
		});
		dialogManager.addButton( "아니오" );
		dialogManager.display( true );
		
		return confirmResult;
		
	}
	
}
